package com.fancy.learncenter.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.activity.PersonInfoActivity;
import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.FollowDataBean;
import com.superservice.lya.R;

import java.util.ArrayList;

/**
 * Created by hyy on 2018/1/27.
 * Explain activity as
 */

public class FollowMyAdapter extends CommonRecycleViewAdapter<FollowDataBean> {

    public FollowMyAdapter(Context mContext, ArrayList<FollowDataBean> itemDatas) {
        super(mContext, R.layout.fragment_guanzhu_item, itemDatas);
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final FollowDataBean item, int position) {

        SimpleDraweeView simpleDraweeView = customViewHold.getView(R.id.simpleDraweeView);
        simpleDraweeView.setImageURI(item.getImgsrc());

        TextView name = customViewHold.getView(R.id.name);
        name.setText(item.getNick_name());

        TextView follow_num = customViewHold.getView(R.id.follow_num);
        follow_num.setText("关注" + item.getFollow());


        TextView fun_num = customViewHold.getView(R.id.fun_num);
        fun_num.setText("粉丝" + item.getFun());

        TextView submit = customViewHold.getView(R.id.submit);
        submit.setText("添加关注" );
        simpleDraweeView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, PersonInfoActivity.class);
                intent.putExtra(PersonInfoActivity.USER_KEY, item.getUser_id());
                mContext.startActivity(intent);
            }
        });

        submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickCallBack.onClickCallBack(item);
            }
        });
    }

    private MyFollowAdapter.OnClickCallBack onClickCallBack;

    public MyFollowAdapter.OnClickCallBack getOnClickCallBack() {
        return onClickCallBack;
    }

    public void setOnClickCallBack(MyFollowAdapter.OnClickCallBack onClickCallBack) {
        this.onClickCallBack = onClickCallBack;
    }

    public interface OnClickCallBack {
        abstract void onClickCallBack(FollowDataBean item);
    }
}
